<template>
  <div>
    <tabs />
    <div class="survey">
      <div class="survey-box">
        <el-row type="flex" justify="space-between" align="middle" class="survey-hedaer">
          <div class="title">总览概况</div>
          <!-- <el-link :underline="false" type="primary">查看详情</el-link> -->
        </el-row>
        <el-row class="survey-user" type="flex" justify="space-between">
          <div class="item">
            <div class="limit">销售额({{ site.money_title }})</div>
            <div class="number"><count-roll :number="response.sale_price" :is-money="true" /></div>
            <div class="before">
              昨日：
              <span>{{ response.yesterday_sale_price }}</span>
            </div>
          </div>
          <div class="item">
            <div class="limit">收益额({{ site.money_title }})</div>
            <div class="number"><count-roll :number="response.income" :is-money="true" /></div>
            <div class="before">
              昨日：
              <span>{{ response.yesterday_income }}</span>
            </div>
          </div>
          <div class="item">
            <div class="limit">独立访客数(UV)</div>
            <div class="number"><count-roll :number="response.uv" /></div>
            <div class="before">
              昨日：
              <span>{{ response.yesterday_uv }}</span>
            </div>
          </div>
          <div class="item">
            <div class="limit">访问量(PV)</div>
            <div class="number"><count-roll :number="response.pv" /></div>
            <div class="before">
              昨日：
              <span>{{ response.yesterday_pv }}</span>
            </div>
          </div>
          <div class="item">
            <div class="limit">付费用户数</div>
            <div class="number"><count-roll :number="response.payment_user_count" /></div>
            <div class="before">
              昨日：
              <span>{{ response.yesterday_payment_user_count }}</span>
            </div>
          </div>
          <div class="item">
            <div class="limit">支付订单数</div>
            <div class="number"><count-roll :number="response.payment_order_count" /></div>
            <div class="before">
              昨日：
              <span>{{ response.yesterday_payment_order_count }}</span>
            </div>
          </div>
        </el-row>
      </div>
      <!-- 运营概况 -->
      <operate link-url="/data/analysis/transaction" />
      <!-- 流量看板 -->
      <flow-column link-url="/data/analysis/visit" />
      <!-- 下单转化率 -->
      <order-conversion link-url="/data/analysis/transaction" />
      <!-- 课程看板 -->
      <course-column link-url="/data/analysis/course" />
      <!-- 用户看板 -->
      <user-column link-url="/data/analysis/student" />
      <!-- 其他 -->
      <!--  <div class="other">
        <el-row type="flex" justify="space-between" align="middle" class="survey-hedaer">
          <div class="title">其他</div>
          <el-link :underline="false" type="primary">查看详情</el-link>
        </el-row>
        <el-row :gutter="70">
          <el-col :span="12">
            <div class="other-title">考试</div>
            <el-row :gutter="43">
              <el-col :span="12">
                <div class="other-item">
                  <el-row type="flex" justify="space-between" align="middle">
                    <div class="title">今日收入</div>
                    <div class="num">订单数：21单</div>
                  </el-row>
                  <div class="price">¥32.00</div>
                </div>
              </el-col>
              <el-col :span="12">
                <div class="other-item">
                  <el-row type="flex" justify="space-between" align="middle">
                    <div class="title">累计收入</div>
                  </el-row>
                  <div class="price">¥32.00</div>
                </div>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="12">
            <div class="other-title">问答</div>
            <el-row :gutter="43">
              <el-col :span="12">
                <div class="other-item">
                  <el-row type="flex" justify="space-between" align="middle">
                    <div class="title">今日收入</div>
                  </el-row>
                  <div class="price">¥32.00</div>
                </div>
              </el-col>
              <el-col :span="12">
                <div class="other-item">
                  <el-row type="flex" justify="space-between" align="middle">
                    <div class="title">累计收入</div>
                  </el-row>
                  <div class="price">¥32.00</div>
                </div>
              </el-col>
            </el-row>
          </el-col>
        </el-row>
      </div> -->

      <!-- 商品看板 -->
      <!-- <div class="good-column">
        <el-row type="flex" justify="space-between" align="middle" class="survey-hedaer">
          <div class="title">用户看板</div>
          <el-link :underline="false" type="primary">查看详情</el-link>
        </el-row>
        <el-row :gutter="70">
          <el-col :span="12">
            <div class="good-column-item">
              <div class="good-column-title">访问榜TOP5</div>
              <el-table></el-table>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="good-column-item">
              <div class="good-column-title">兑换榜TOP5</div>
              <el-table></el-table>
            </div>
          </el-col>
        </el-row>
      </div> -->
    </div>
  </div>
</template>

<script>
import Tabs from '../tabs/index.vue';
import Operate from '@/pages/vcharts/box/operate/index.vue';
import FlowColumn from '@/pages/vcharts/box/flow/index.vue';
import OrderConversion from '@/pages/vcharts/box/order_conversion/index.vue';
import CourseColumn from '@/pages/vcharts/box/course/index.vue';
import CountRoll from '@/pages/data/components/count_roll';
import UserColumn from '@/pages/vcharts/box/student/index.vue';

export default {
  components: {
    Tabs,
    Operate,
    FlowColumn,
    OrderConversion,
    CourseColumn,
    CountRoll,
    UserColumn
  },
  data() {
    return {
      response: {
        payment_order_count: 0,
        payment_user_count: 0,
        pv: 0,
        sale_price: 0,
        income: 0,
        uv: 0,
        yesterday_payment_order_count: 0,
        yesterday_payment_user_count: 0,
        yesterday_pv: 0,
        yesterday_sale_price: 0,
        yesterday_income: 0,
        yesterday_uv: 0
      }
    };
  },
  computed: {
    sale_price_float() {
      return this.response.sale_price - this.response.yesterday_sale_price;
    },
    pv_float() {
      return this.response.pv - this.response.yesterday_pv;
    },
    uv_float() {
      return this.response.uv - this.response.yesterday_uv;
    },
    payment_user_count_float() {
      return this.response.payment_user_count - this.response.yesterday_payment_user_count;
    },
    payment_order_count_float() {
      return this.response.payment_order_count - this.response.yesterday_payment_order_count;
    }
  },
  created() {
    this.$http.get(
      '/admin/data/survey',
      {},
      response => {
        this.response = response.data;
      },
      errror => {},
      false
    );
  },
  mounted() {
    this.$store.dispatch('setLoading', 0);
  },
  methods: {
    changeOrderTime: function(time) {
      this.$message.success(time);
    }
  }
};
</script>

<style lang="scss" scoped>
.survey {
  background-color: #f8f8f8;
  padding-right: 27px;
  padding-bottom: 16px;
  .survey-box {
    background-color: #fff;
    min-height: 150px;
    margin-bottom: 20px;
    padding: 10px 20px 25px;
  }
  .survey-hedaer {
    margin-bottom: 28px;
    height: 36px;
    padding-right: 20px;
    background-color: #f1f8ff;
    .title {
      color: #303133;
      font-size: 15px;
      padding-left: 6px;
      border-left: 2px solid #5191ff;
    }
  }
  .survey-user {
    .item {
      width: calc(15% - 50px);
      border-radius: 4px;
      padding: 20px;
      &:nth-child(1) {
        background: linear-gradient(226deg, rgba(115, 164, 255, 1) 0%, rgba(60, 143, 255, 1) 100%);
      }
      &:nth-child(2) {
        background: linear-gradient(226deg, rgba(255, 172, 118, 1) 0%, rgba(255, 142, 70, 1) 100%);
      }
      &:nth-child(3) {
        background: linear-gradient(225deg, rgba(173, 232, 89, 1) 0%, rgba(131, 219, 49, 1) 100%);
      }
      &:nth-child(4) {
        background: linear-gradient(226deg, rgba(255, 149, 132, 1) 0%, rgba(255, 113, 105, 1) 100%);
      }
      &:nth-child(5) {
        background: linear-gradient(45deg, rgba(123, 114, 255, 1) 0%, rgba(135, 161, 255, 1) 100%);
      }
      &:nth-child(6) {
        background: linear-gradient(45deg, rgba(255, 171, 236, 1.0) 0%, rgba(245, 185, 255, 1.0) 100%);
      }
      .limit {
        color: #fff;
        font-size: 16px;
        letter-spacing: 1px;
      }
      .number {
        margin-top: 7px;
        color: #fff;
        font-size: 26px;
        font-weight: bold;
      }
      .before {
        margin-top: 10px;
        color: #fff;
        font-size: 13px;
      }
    }
  }
}

.other {
  background-color: #fff;
  padding: 10px 20px 25px;
  margin-bottom: 20px;
  .other-title {
    width: 423px;
    height: 30px;
    color: #303133;
    font-size: 14px;
    line-height: 30px;
    padding: 0 10px;
    margin-bottom: 24px;
    background: linear-gradient(90deg, rgba(244, 249, 255, 1) 0%, rgba(255, 255, 255, 1) 100%);
  }
  .other-item {
    padding: 29px 20px 32px 35px;
    border-radius: 4px;
    border: 1px solid #dcdfe6;
    .title {
      color: #303133;
      font-size: 14px;
    }
    .num {
      color: #606266;
      font-size: 13px;
    }
    .price {
      margin-top: 35px;
      color: #f54030;
      font-size: 26px;
      font-weight: bold;
    }
  }
}

.good-column {
  background-color: #fff;
  padding: 10px 20px 25px;
  margin-top: 20px;
  .good-column-item {
    border: 1px solid #dcdfe6;
    border-bottom: none;
    ::v-deep.el-table__header-wrapper th {
      background-color: #f6f9ff;
    }
  }
  .good-column-title {
    font-size: 16px;
    color: #303133;
    text-align: center;
    padding: 22px 0;
  }
}
</style>
